package com.xy.farm.activity.base;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.xy.farm.R;

/**
 * Created by 1174607250 on 2018/8/2.
 */

public class BaseActivity extends AppCompatActivity implements View.OnClickListener
{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        else
            findViewById(R.id.status_bar).setVisibility(View.GONE);

    }
    public void setTitle(String str)
    {
        TextView textView = findViewById(R.id.tv_title);
        textView.getPaint().setFakeBoldText(true);
        textView.setText(str);
    }
    @Override
    public void onClick(View v)
    {
        switch (v.getId())
        {
            case R.id.btn_back:
                super.onBackPressed();
                break;
        }
    }
    private Toast toast;
    public void showShortToast(String str)
    {
        if (toast != null)
            toast.cancel();
        (toast = Toast.makeText(this, str, Toast.LENGTH_SHORT)).show();
    }
    public void showLongToast(String str)
    {
        if (toast != null)
            toast.cancel();
        (toast = Toast.makeText(this, str, Toast.LENGTH_LONG)).show();
    }
}
